package com.baiwei.vpnapi.controller;

import com.baiwei.vpnapi.entity.reqentity.ChannelStatInput;
import com.baiwei.vpnapi.service.impl.AdminServiceImpl;
import com.baiwei.vpnapi.utils.ResultVoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;

/**
 * @program: vpnapi
 * @description: admin统计相关接口
 * @author: Mr. Stone
 * @create: 2020-03-13 20:19
 **/

@RestController
@RequestMapping("stat")
public class AdminController {
    @Autowired
    private HttpServletRequest request;

    @Autowired
    private AdminServiceImpl adminService;

    static Integer adClickTypeId = 5;

    @PostMapping("advert/{actionType}")
    Object statAdvert(@PathVariable Integer actionType,@RequestBody ChannelStatInput input) {
        return ResultVoUtils.success(adminService.statAdvert(actionType, input));
    }

    @PostMapping("action/{actionType}")
    Object statAction(@PathVariable Integer actionType, @RequestBody(required = false) ChannelStatInput input) {
        Integer platform = new Integer(request.getHeader("platform"));
        return ResultVoUtils.success(adminService.statAction(actionType, null, null, platform, input));
    }
}
